// 图论：

class Solution {
public:

    vector<vector<int>> res;

    vector<int> path;

    vector<vector<int>> allPathsSourceTarget(vector<vector<int>>& graph)
    {
        int n = graph.size();

        traverse(graph, 0);

        return res;
    }

    void traverse(vector<vector<int>>& graph, int s)
    {
        int n = graph.size();

        path.push_back(s);

        // 找到终点
        if(s == n - 1)
        {
            res.push_back(path);
            path.pop_back();
            return;
        }

        for(int v : graph[s])
        {
            traverse(graph, v);
        }

        path.pop_back();
    }
};



